package com.itheima.controller;



import com.itheima.util.R;
import com.itheima.domain.PmsSkuStock;
import com.itheima.manager.PmsSkuStockManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("sku")
public class PmsSkuStockController {


    @Autowired
    private PmsSkuStockManager pmsSkuStockManager;

    /**
     * 批量更新sku库存信息
     * @param pid
     * @param
     * @return
     */
    @PostMapping("update/{pid}")
    public R updatePid(@PathVariable  Integer pid,@RequestBody PmsSkuStock[] skuStockList){
        pmsSkuStockManager.updatePid(pid,skuStockList);
        return R.success("");
    }


    @GetMapping("/{pid}")
    public R getByIdSku(@PathVariable Integer pid, String keyword){

        List<PmsSkuStock> pmsSkuStock = pmsSkuStockManager.getByIdSku(pid, keyword);

        return R.success(pmsSkuStock);
    }


}